home *** CD-ROM | disk | FTP | other *** search
- class BigKid extends MovieClip
- {
- var glevel;
- var is_available;
- var direction;
- var available_to_hit;
- var move_speed;
- var ground;
- var hypnotized;
- var BOUNDS;
- var onEnterFrame;
- var interval_id;
- var last_escalator;
- function BigKid()
- {
- super();
- this._name = "BigKid";
- _global[this._name] = this;
- this.glevel = random(3) + 1;
- this.is_available = true;
- this.direction = -1;
- this.available_to_hit = true;
- this.move_speed = 5.5;
- this.ground = _global.MallCrawl["GLevel" + this.glevel]._y - this._height;
- this._y = this.ground;
- this.hypnotized = false;
- this.BOUNDS = {left:0,right:_global.MallCrawl.Background._width - this._width};
- this.gotoAndStop("walk");
- this.onEnterFrame = this.defaultEnterFrame;
- }
- function defaultEnterFrame()
- {
- if(!_global.MallCrawl.paused)
- {
- if(this.hitTest(_global.Rescuer) && this.is_available && this.available_to_hit && !_global.Rescuer.invincible)
- {
- _global.Rescuer.loseFollower();
- this.available_to_hit = false;
- }
- else if(!this.hitTest(_global.Rescuer) && !this.available_to_hit)
- {
- this.available_to_hit = true;
- }
- if(this.is_available)
- {
- if(this.direction > 0)
- {
- this.moveRight();
- }
- else
- {
- this.moveLeft();
- }
- this.checkForEscalators();
- this.checkBounds();
- }
- else
- {
- this._y = this.ground;
- }
- }
- }
- function checkForEscalators()
- {
- var _loc3_ = 0;
- while(_loc3_ < _global.MallCrawl.upEscalators.length)
- {
- if(this.hitTest(_global.MallCrawl.upEscalators[_loc3_].HitSquare) && this.glevel < 3 && this.chance())
- {
- this.rideEscalator(_global.MallCrawl.upEscalators[_loc3_]);
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc3_ = 0;
- while(_loc3_ < _global.MallCrawl.downEscalators.length)
- {
- if(this.hitTest(_global.MallCrawl.downEscalators[_loc3_].HitSquare) && this.glevel > 1 && this.chance())
- {
- this.rideEscalator(_global.MallCrawl.downEscalators[_loc3_]);
- }
- _loc3_ = _loc3_ + 1;
- }
- }
- function chance()
- {
- var _loc1_ = 30;
- var _loc2_ = random(_loc1_);
- if(_loc2_ === 0)
- {
- return true;
- }
- return false;
- }
- function escalate(escalator)
- {
- if(!this.hypnotized)
- {
- if(escalator.direction < 0)
- {
- if(this._y + this._height > escalator._y)
- {
- this.moveRight(1);
- this.ground -= 1;
- }
- else
- {
- this.is_available = true;
- this.resetGround();
- clearInterval(this.interval_id);
- }
- }
- else if(this._y + this._height < escalator._y + escalator._height)
- {
- this.moveRight(1);
- this.ground += 1;
- }
- else
- {
- this.is_available = true;
- this.resetGround();
- clearInterval(this.interval_id);
- }
- }
- }
- function hypnotize()
- {
- this.gotoAndStop("head_bang");
- this.hypnotized = true;
- delete this.onEnterFrame;
- }
- function rideEscalator(escalator)
- {
- if(this._x < escalator._x && this._x + this._width > escalator._x && this.last_escalator != escalator)
- {
- this.is_available = false;
- this.last_escalator = escalator;
- escalator.activate(this);
- }
- }
- function checkBounds()
- {
- if(this._x < this.BOUNDS.left)
- {
- this.direction *= -1;
- }
- else if(this._x > this.BOUNDS.right)
- {
- this.direction *= -1;
- }
- }
- function resetGround()
- {
- this.ground = _global.MallCrawl["GLevel" + this.glevel]._y - this._height;
- this._y = this.ground;
- }
- function moveLeft(speed)
- {
- !!speed ? null : (speed = this.move_speed);
- this._xscale >= 0 ? null : (this._xscale *= -1);
- this._x -= speed;
- }
- function moveRight(speed)
- {
- !!speed ? null : (speed = this.move_speed);
- this._xscale <= 0 ? null : (this._xscale *= -1);
- this._x += speed;
- }
- }
-